<include file="Common/header" />
<title>会员录入</title>
<script type="text/javascript" src="__PUBLIC__/h-ui/lib/jquery/1.9.1/jquery.form.js"></script>
</head>
<body>
<div class="pd-20">
	<form action="" method="post" class="form form-horizontal" id="form-user-character-add" enctype="multipart/form-data">
		<div class="panel panel-primary">
			<div class="panel-header">基本信息</div> 
			<table class="table table-border table-bordered table-striped">
	            <tr>
	               	<td style="background-color: #f9f9f9;text-align: right">客人姓名：</td>
	                <td style="background-color: white">
						<input type="hidden" name="userid" id="userid" value="{$userinfo['userid']}" />
						<input type="text" name="nickname" id="nickname" class="input-text radius" value="{$userinfo['nickname']}" />
					</td>
					<td style="background-color: #f9f9f9;text-align: right">身份证：</td>
	                <td style="background-color: white;">
						<input type="text" name="card" id="card" class="input-text radius" value="{$userinfo['card']}" />
	                </td>
					<td style="background-color: #f9f9f9;text-align: right">联系方式：</td>
	                <td style="background-color: white">
						<input type="text" name="phone" id="phone" class="input-text radius" value="{$userinfo['phone']}" />
					</td>
	            </tr>
				<tr>
					<td style="background-color: #f9f9f9;text-align: right">紧急联系人：</td>
	                <td style="background-color: white">
						<input type="text" name="emergency_name" id="emergency_name" class="input-text radius" value="{$userinfo['emergency_name']}" />
					</td>
					<td style="background-color: #f9f9f9;text-align: right">紧急联系方式：</td>
	                <td style="background-color: white">
						<input type="text" name="emergency_phone" id="emergency_phone" class="input-text radius" value="{$userinfo['emergency_phone']}" />
					</td>
					<td style="background-color: #f9f9f9;text-align: right">性别：</td>
	                <td style="background-color: white">
						<span class="select-box radius">
						<select class="select radius" id="sex" name="sex">
							<option value="1" <?php echo $userinfo['sex'] == 1 ? 'selected' : '';?>>男</option>
							<option value="2" <?php echo $userinfo['sex'] == 2 ? 'selected' : '';?>>女</option>
						</select>
					</span>
					</td>
				</tr>
				<tr>
					<td style="background-color: #f9f9f9;text-align: right">联系地址：</td>
	                <td style="background-color: white" colspan="6">
						<input type="text" name="address" id="address" class="input-text radius" value="{$userinfo['address']}" />
					</td>
				</tr>
			</table>
		</div>

		<div class="mt-5 mb-5 text-c">
			<button type="button" class="btn btn-success radius submitBtn" id="admin-role-save" name="admin-role-save">
				<i class="icon-ok"></i> 确  定
			</button>
		</div>

		<div class="panel panel-success">
			<div class="panel-header">三方关联账号</div> 
			<table class="table table-border table-bordered table-striped">
	            <tr>
	               	<td style="background-color: #f9f9f9;text-align: right; width: 80px;">账号类型：</td>
	                <td style="background-color: white">
						<?php if($userinfo['login_type'] == 2){ ?>
						微信
						<?php }else if($userinfo['login_type'] == 3){ ?>
						QQ
						<?php } ?>
					</td>
				</tr>
				<tr>	
					<td style="background-color: #f9f9f9;text-align: right">账号标识：</td>
	                <td style="background-color: white;">
						{$userinfo['login_uuid']}
	                </td>
	            </tr>
	            <tr>    
					<td style="background-color: #f9f9f9;text-align: right">账号昵称：</td>
	                <td style="background-color: white">
						{$userinfo['login_nick']}
					</td>
	            </tr>
	            <tr>    
					<td style="background-color: #f9f9f9;text-align: right">注册时间：</td>
	                <td style="background-color: white">
						{$userinfo['createtime']|date="Y-m-d H:i", ###}
					</td>
	            </tr>
			</table>
		</div>
	</form>
</div>

<script>
	$(document).ready(function(){
		/**
		 * 提交数据
		 **/
		$(".submitBtn").on('click', function(){
			if($("#btime").val() == ""){
				layer.msg("请选择合同开始时间", {icon: 2, time:2000});
				return false;
			}
			
			if($("#etime").val() == ""){
				layer.msg("请选择合同截止时间", {icon: 2, time:2000});
				return false;
			}

			var nickname = $("#member_nick").val();
			if(nickname.length > 20){
				layer.msg('姓名长度在1～20个字符之间', {icon: 5, time: 2000});
				return false;
			}
			
			var load = layer.load(2);
			$.post('add.html', $("#form-user-character-add").serialize(), function(data){
				layer.close(load);
				if(data == '操作成功'){
					layer.msg(data, {icon: 1, time: 2000}, function(){
						window.parent.location.reload(); //刷新
						var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
                    	parent.layer.close(index);
					});
				}else if(data == '请输入管理员密码'){
					var html = '<input type="password" name="pwds" id="pwds" class="input-text radius" />';
					var i = layer.open({
						title: '验证管理员密码',
						content: html,
						yes: function(){
							var password = $("#pwds").val();
							$("#password").val(password);
							layer.close(i);
							$.post('add.html', $("#form-user-character-add").serialize(), function(data){
								if(data == '操作成功'){
									layer.msg(data, {icon: 1, time: 2000}, function(){
										window.parent.location.reload(); //刷新
										var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
										parent.layer.close(index);
									});
								}else{
									layer.msg(data, {icon: 2, time: 2000});
								}
							});
						}
					});
				}else{
					layer.msg(data, {icon: 2, time: 2000});
				}
			});
		});
	});
</script>
</body>
</html>